﻿using Newtonsoft.Json;
using PokemonClientToos.TempModel;
using System;
using System.Collections.Generic;
using System.Drawing;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace PokemonClientToos.Entity
{
    public class AllCache
    {
        private AllCache() { }
        public static readonly AllCache instance = new AllCache();
        public List<TempAction> actionList = new List<TempAction>();
        public string ActionSettingPath = string.Format(@"{0}\{1}", Application.StartupPath, @"Setting\ActionPar.txt");

        public void Load()
        {
            // 加载接口文件信息
            if (!File.Exists(AllCache.instance.ActionSettingPath))
            {
                File.Create(AllCache.instance.ActionSettingPath);
            }
            else
            {
                StreamReader reader = new StreamReader(AllCache.instance.ActionSettingPath, Encoding.Default);
                string fileData = reader.ReadToEnd();
                List<TempAction> actionList = JsonConvert.DeserializeObject<List<TempAction>>(fileData);
                if (actionList != null)
                {
                    AllCache.instance.actionList = actionList;
                }
                reader.Close();
            }

            colorList.Add(Color.Purple);
            for (int i = 0; i < 20; i++)
            {

            }
        }

        public void Write()
        {
            // 加载接口文件信息
            if (File.Exists(AllCache.instance.ActionSettingPath))
            {
                StreamWriter sw = new StreamWriter(AllCache.instance.ActionSettingPath);
                string data = JsonConvert.SerializeObject(AllCache.instance.actionList);
                sw.Write(data);
                sw.Close();
            }
        }

        public static List<Color> colorList = new List<Color>();
    }
}
